import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: ScaleAnimationExample1());
  }
}

class ScaleAnimationExample1 extends StatefulWidget {
  @override
  _ScaleAnimationExample1State createState() => _ScaleAnimationExample1State();
}

class _ScaleAnimationExample1State extends State<ScaleAnimationExample1> {
  //
  double scale = 1.0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('缩放动画示例')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            AnimatedContainer(
              duration: Duration(seconds: 1),
              transform: Matrix4.identity()
                //scale(x/w,y/w,z/w)
                ..scaleByDouble(scale, scale, 1.0, 1.0),
              child: Container(width: 200, height: 200, color: Colors.blue),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.change_circle_outlined),
        onPressed: () {
          setState(() {
            scale = scale == 1.0 ? 1.5 : 1.0;
          });
        },
      ),
    );
  }
}
